//
//  UtilsMacros.h
//
//

#ifndef UtilsMacros_h
#define UtilsMacros_h


//=============== 网络相关 ==================
#define BaseUrl @"https://qm.music.lingximusic.com/"
#define QiNiuBaseUrl @"https://static.music.lingximusic.com/"


//=============== 机型相关 ==================
#define iOS10Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.0f)
#define iOS11Later ([UIDevice currentDevice].systemVersion.floatValue >= 11.0f)
#define iOS12Later ([UIDevice currentDevice].systemVersion.floatValue >= 12.0f)
#define iOS13Later ([UIDevice currentDevice].systemVersion.floatValue >= 13.0f)
#define iOS14Later ([UIDevice currentDevice].systemVersion.floatValue >= 14.0f)

#define  KScreen_W             ([UIScreen mainScreen].bounds.size.width)
#define  KScreen_H             ([UIScreen mainScreen].bounds.size.height)
#define  kStatusBarHeight      ([Tools safeAreaInsetstop])

////宽的比例
//#define Ratio(R) (R)*KScreen_W/375.0
//
//#define RatioH(R) (R)*KScreen_H/375.0

//宽的比例
#define Ratio(R) (R)*KScreen_W/375.0

#define RatioH(R) (R)*KScreen_H/375.0

#define New_Ratio(R) (R)

#define New_RatioH(R) (R)
//状态栏高度
#define  KBaseNavi_Height      44
#define  KSafeAreaBottomHeight ([Tools safeAreaInsetsbottom])// 底部安全区域距离
#define  KNav_H                (kStatusBarHeight+KBaseNavi_Height)
#define  KTab_H                (49+KSafeAreaBottomHeight)
#define  KDif_H                (kStatusBarHeight - 24)
#define  GETPIXEL              (KScreen_W / 375) //按375屏宽设置 获取像素比
#define  K_AUTOLAYOUT_W(with) (with * GETPIXEL)

#define  GETPIXEL1              (KScreen_W / 667) //按375屏宽设置 获取像素比
#define  K_AUTOLAYOUT_W1(with) (with * GETPIXEL1)
//=============== image ==================
#define KImageNamed(name)    [UIImage imageNamed:(name)]
#define KImageUrl(url)       [url hasPrefix:@"http"] ? [NSURL URLWithString:url]:[NSURL URLWithString:url relativeToURL:[NSURL URLWithString:QiNiuBaseUrl]]
#define KImageUrlString(url) [url hasPrefix:@"http"] ? url:[NSString stringWithFormat:@"%@%@",QiNiuBaseUrl,url]

//=============== 便捷方法 ==================
#define KWeak(name,weakName)  __weak typeof(name) weakName = name;
#define KWeakSelf   __weak typeof(self) weakSelf = self;
#define KStrongSelf   __strong typeof(self) strongSelf = weakSelf;//只能修饰weakSelf 用来为了防止弱引用内存提前释放

#define ShowHud(String)  [MyLoadView showMessageAutoHide:String];
#define ShowMBLoading [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].delegate.window animated:YES];
#define HideMBLoading [MBProgressHUD hideHUDForView:[UIApplication sharedApplication].delegate.window animated:YES];


//NSUserDefaults取值 同步存值
#define USERDEFAULT_GetValue(key) [[NSUserDefaults standardUserDefaults] valueForKey:key]
#define USERDEFAULT_SetValue(_value_,_key_) [[NSUserDefaults standardUserDefaults] setValue:_value_ forKey:_key_];\
[[NSUserDefaults standardUserDefaults] synchronize]

//账户
#define KIsLogin  @"LabourItem_isLogin"
#define KUserInfo @"LabourItem_userInfo"

#define KwxRefreshToken @"LabourItem_KwxRefreshToken"//30天有效期
#define KwxOpenId @"LabourItem_KwxOpenId"


// UILabel 初始化
#define UILABEL_ALLOC(X,Y,x,y) [[UILabel alloc] initWithFrame:CGRectMake(X,Y,x,y)]
// UITextField 初始化
#define UITEXTFIELD_ALLOC(X,Y,x,y) [[UITextField alloc] initWithFrame:CGRectMake(X,Y,x,y)]
// UIView 初始化
#define UIVIEW_ALLOC(X,Y,x,y) [[UIView alloc] initWithFrame:CGRectMake(X,Y,x,y)]
// UIImageView 初始化
#define UIIMAGEVIEW_ALLOC(X,Y,x,y) [[UIImageView alloc] initWithFrame:CGRectMake(X,Y,x,y)]

//=============== log =================
//#ifdef DEBUG
//#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d  \t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//#else
//#define NSLog(FORMAT, ...) nil
//#endif

#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define NSLog(...)
#define debugMethod()
#endif



#endif /* UtilsMacros_h */
